package com.chuangyang.fixboxmaster.utils;

import java.util.Calendar;
import java.util.Date;

/**
 * Created by vanshu on 16/1/11 17:39.
 */
public class DateUtils {

    public static Calendar getDateAfterOrBefore(Date date,int position){
        Calendar now =Calendar.getInstance();
        now.setTime(date);
        now.set(Calendar.DATE,now.get(Calendar.DATE)+position);
        return now;
    }


    public static String printCalendar(Calendar cl){
//        int year = cl.get(Calendar.YEAR);
        String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
        int month = cl.get(Calendar.MONTH)+1;
        int day = cl.get(Calendar.DATE);
        int week=cl.get(Calendar.DAY_OF_WEEK) - 1;
        if (week < 0)
            week = 0;
        return weekDays[week]+""+month+"月"+day+"日";
    }


    public static String printCalendarWithOutWeek(Calendar cl){
        int year = cl.get(Calendar.YEAR);
        int month = cl.get(Calendar.MONTH)+1;
        int day = cl.get(Calendar.DATE);
        return year+"-"+month+"-"+day;
    }


    public static String generateDate(Calendar cl){
        int year = cl.get(Calendar.YEAR);
        int month = cl.get(Calendar.MONTH)+1;
        int day = cl.get(Calendar.DATE);
        return year+"-"+month+"-"+day;
    }
}
